


<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <script type="text/javascript">

      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-90545585-1']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>torchvision.transforms &mdash; Torchvision master documentation</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <!-- <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> -->
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="torchvision.utils" href="utils.html" />
    <link rel="prev" title="torchvision.ops" href="ops.html" /> 

  
  <script src="_static/js/modernizr.min.js"></script>

  <!-- Preload the theme fonts -->

<link rel="preload" href="_static/fonts/FreightSans/freight-sans-book.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/FreightSans/freight-sans-medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/IBMPlexMono/IBMPlexMono-Medium.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/FreightSans/freight-sans-bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/FreightSans/freight-sans-medium-italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="_static/fonts/IBMPlexMono/IBMPlexMono-SemiBold.woff2" as="font" type="font/woff2" crossorigin="anonymous">

<!-- Preload the katex fonts -->

<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Math-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Main-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Main-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size1-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size4-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size2-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Size3-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
<link rel="preload" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/fonts/KaTeX_Caligraphic-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
</head>

<div class="container-fluid header-holder tutorials-header" id="header-holder">
  <div class="container">
    <div class="header-container">
      <a class="header-logo" href="https://pytorch.org/" aria-label="PyTorch"></a>

      <div class="main-menu">
        <ul>
          <li>
            <a href="https://pytorch.org/get-started">Get Started</a>
          </li>

          <li>
            <div class="ecosystem-dropdown">
              <a id="dropdownMenuButton" data-toggle="ecosystem-dropdown">
                Ecosystem
              </a>
              <div class="ecosystem-dropdown-menu">
                <a class="nav-dropdown-item" href="https://pytorch.org/hub"">
                  <span class=dropdown-title>Models (Beta)</span>
                  <p>Discover, publish, and reuse pre-trained models</p>
                </a>
                <a class="nav-dropdown-item" href="https://pytorch.org/ecosystem">
                  <span class=dropdown-title>Tools & Libraries</span>
                  <p>Explore the ecosystem of tools and libraries</p>
                </a>
              </div>
            </div>
          </li>

          <li>
            <a href="https://pytorch.org/mobile">Mobile</a>
          </li>

          <li>
            <a href="https://pytorch.org/blog/">Blog</a>
          </li>

          <li>
            <a href="https://pytorch.org/tutorials">Tutorials</a>
          </li>

          <li class="active">
            <a href="https://pytorch.org/docs/stable/index.html">Docs</a>
          </li>

          <li>
            <div class="resources-dropdown">
              <a id="resourcesDropdownButton" data-toggle="resources-dropdown">
                Resources
              </a>
              <div class="resources-dropdown-menu">
                <a class="nav-dropdown-item" href="https://pytorch.org/resources"">
                  <span class=dropdown-title>Developer Resources</span>
                  <p>Find resources and get questions answered</p>
                </a>
                <a class="nav-dropdown-item" href="https://pytorch.org/features">
                  <span class=dropdown-title>About</span>
                  <p>Learn about PyTorch’s features and capabilities</p>
                </a>
              </div>
            </div>
          </li>

          <li>
            <a href="https://github.com/pytorch/pytorch">Github</a>
          </li>
        </ul>
      </div>

      <a class="main-menu-open-button" href="#" data-behavior="open-mobile-menu"></a>
    </div>

  </div>
</div>


<body class="pytorch-body">

   

    

    <div class="table-of-contents-link-wrapper">
      <span>Table of Contents</span>
      <a href="#" class="toggle-table-of-contents" data-behavior="toggle-table-of-contents"></a>
    </div>

    <nav data-toggle="wy-nav-shift" class="pytorch-left-menu" id="pytorch-left-menu">
      <div class="pytorch-side-scroll">
        <div class="pytorch-menu pytorch-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          <div class="pytorch-left-menu-search">
            

            
              
              
                <div class="version">
                  master (0.6.0 )
                </div>
              
            

            


  


<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search Docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

            
          </div>

          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Package Reference</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="datasets.html">torchvision.datasets</a></li>
<li class="toctree-l1"><a class="reference internal" href="io.html">torchvision.io</a></li>
<li class="toctree-l1"><a class="reference internal" href="models.html">torchvision.models</a></li>
<li class="toctree-l1"><a class="reference internal" href="ops.html">torchvision.ops</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">torchvision.transforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="utils.html">torchvision.utils</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <div class="pytorch-container">
      <div class="pytorch-page-level-bar" id="pytorch-page-level-bar">
        <div class="pytorch-breadcrumbs-wrapper">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="pytorch-breadcrumbs">
    
      <li>
        <a href="index.html">
          
            Docs
          
        </a> &gt;
      </li>

        
      <li>torchvision.transforms</li>
    
    
      <li class="pytorch-breadcrumbs-aside">
        
            
            <a href="_sources/transforms.rst.txt" rel="nofollow"><img src="_static/images/view-page-source-icon.svg"></a>
          
        
      </li>
    
  </ul>

  
</div>
        </div>

        <div class="pytorch-shortcuts-wrapper" id="pytorch-shortcuts-wrapper">
          Shortcuts
        </div>
      </div>

      <section data-toggle="wy-nav-shift" id="pytorch-content-wrap" class="pytorch-content-wrap">
        <div class="pytorch-content-left">

        
          
          <div class="rst-content">
          
            <div role="main" class="main-content" itemscope="itemscope" itemtype="http://schema.org/Article">
             <article itemprop="articleBody" id="pytorch-article" class="pytorch-article">
              
  <div class="section" id="torchvision-transforms">
<h1>torchvision.transforms<a class="headerlink" href="#torchvision-transforms" title="Permalink to this headline">¶</a></h1>
<p>Transforms are common image transformations. They can be chained together using <a class="reference internal" href="#torchvision.transforms.Compose" title="torchvision.transforms.Compose"><code class="xref py py-class docutils literal notranslate"><span class="pre">Compose</span></code></a>.
Additionally, there is the <a class="reference internal" href="#module-torchvision.transforms.functional" title="torchvision.transforms.functional"><code class="xref py py-mod docutils literal notranslate"><span class="pre">torchvision.transforms.functional</span></code></a> module.
Functional transforms give fine-grained control over the transformations.
This is useful if you have to build a more complex transformation pipeline
(e.g. in the case of segmentation tasks).</p>
<dl class="class">
<dt id="torchvision.transforms.Compose">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Compose</code><span class="sig-paren">(</span><em>transforms</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Compose"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Compose" title="Permalink to this definition">¶</a></dt>
<dd><p>Composes several transforms together.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>transforms</strong> (list of <code class="docutils literal notranslate"><span class="pre">Transform</span></code> objects) – list of transforms to compose.</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">transforms</span><span class="o">.</span><span class="n">Compose</span><span class="p">([</span>
<span class="gp">&gt;&gt;&gt; </span>    <span class="n">transforms</span><span class="o">.</span><span class="n">CenterCrop</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span>
<span class="gp">&gt;&gt;&gt; </span>    <span class="n">transforms</span><span class="o">.</span><span class="n">ToTensor</span><span class="p">(),</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">])</span>
</pre></div>
</div>
</dd></dl>

<div class="section" id="transforms-on-pil-image">
<h2>Transforms on PIL Image<a class="headerlink" href="#transforms-on-pil-image" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.CenterCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">CenterCrop</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#CenterCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.CenterCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crops the given PIL Image at the center.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.ColorJitter">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">ColorJitter</code><span class="sig-paren">(</span><em>brightness=0</em>, <em>contrast=0</em>, <em>saturation=0</em>, <em>hue=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#ColorJitter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ColorJitter" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly change the brightness, contrast and saturation of an image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>brightness</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><em>tuple of python:float</em><em> (</em><em>min</em><em>, </em><em>max</em><em>)</em>) – How much to jitter brightness.
brightness_factor is chosen uniformly from [max(0, 1 - brightness), 1 + brightness]
or the given [min, max]. Should be non negative numbers.</li>
<li><strong>contrast</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><em>tuple of python:float</em><em> (</em><em>min</em><em>, </em><em>max</em><em>)</em>) – How much to jitter contrast.
contrast_factor is chosen uniformly from [max(0, 1 - contrast), 1 + contrast]
or the given [min, max]. Should be non negative numbers.</li>
<li><strong>saturation</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><em>tuple of python:float</em><em> (</em><em>min</em><em>, </em><em>max</em><em>)</em>) – How much to jitter saturation.
saturation_factor is chosen uniformly from [max(0, 1 - saturation), 1 + saturation]
or the given [min, max]. Should be non negative numbers.</li>
<li><strong>hue</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><em>tuple of python:float</em><em> (</em><em>min</em><em>, </em><em>max</em><em>)</em>) – How much to jitter hue.
hue_factor is chosen uniformly from [-hue, hue] or the given [min, max].
Should have 0&lt;= hue &lt;= 0.5 or -0.5 &lt;= min &lt;= max &lt;= 0.5.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.FiveCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">FiveCrop</code><span class="sig-paren">(</span><em>size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#FiveCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.FiveCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image into four corners and the central crop</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform returns a tuple of images and there may be a mismatch in the number of
inputs and targets your Dataset returns. See below for an example of how to deal with
this.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size of the crop. If size is an <code class="docutils literal notranslate"><span class="pre">int</span></code>
instead of sequence like (h, w), a square crop of size (size, size) is made.</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">transform</span> <span class="o">=</span> <span class="n">Compose</span><span class="p">([</span>
<span class="gp">&gt;&gt;&gt; </span>   <span class="n">FiveCrop</span><span class="p">(</span><span class="n">size</span><span class="p">),</span> <span class="c1"># this is a list of PIL Images</span>
<span class="gp">&gt;&gt;&gt; </span>   <span class="n">Lambda</span><span class="p">(</span><span class="k">lambda</span> <span class="n">crops</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">stack</span><span class="p">([</span><span class="n">ToTensor</span><span class="p">()(</span><span class="n">crop</span><span class="p">)</span> <span class="k">for</span> <span class="n">crop</span> <span class="ow">in</span> <span class="n">crops</span><span class="p">]))</span> <span class="c1"># returns a 4D tensor</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#In your test loop you can do the following:</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">input</span><span class="p">,</span> <span class="n">target</span> <span class="o">=</span> <span class="n">batch</span> <span class="c1"># input is a 5d tensor, target is 2d</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span> <span class="o">=</span> <span class="nb">input</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">result</span> <span class="o">=</span> <span class="n">model</span><span class="p">(</span><span class="nb">input</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span><span class="p">))</span> <span class="c1"># fuse batch size and ncrops</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">result_avg</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># avg over crops</span>
</pre></div>
</div>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.Grayscale">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Grayscale</code><span class="sig-paren">(</span><em>num_output_channels=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Grayscale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Grayscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert image to grayscale.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>num_output_channels</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – (1 or 3) number of channels desired for output image</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="docutils">
<dt>Grayscale version of the input.</dt>
<dd><ul class="first last simple">
<li>If <code class="docutils literal notranslate"><span class="pre">num_output_channels</span> <span class="pre">==</span> <span class="pre">1</span></code> : returned image is single channel</li>
<li>If <code class="docutils literal notranslate"><span class="pre">num_output_channels</span> <span class="pre">==</span> <span class="pre">3</span></code> : returned image is 3 channel with r == g == b</li>
</ul>
</dd>
</dl>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.Pad">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Pad</code><span class="sig-paren">(</span><em>padding</em>, <em>fill=0</em>, <em>padding_mode='constant'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Pad"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Pad" title="Permalink to this definition">¶</a></dt>
<dd><p>Pad the given PIL Image on all sides with the given “pad” value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>padding</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a>) – Padding on each border. If a single int is provided this
is used to pad all borders. If tuple of length 2 is provided this is the padding
on left/right and top/bottom respectively. If a tuple of length 4 is provided
this is the padding for the left, top, right and bottom borders
respectively.</li>
<li><strong>fill</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a>) – Pixel fill value for constant fill. Default is 0. If a tuple of
length 3, it is used to fill R, G, B channels respectively.
This value is only used when the padding_mode is constant</li>
<li><strong>padding_mode</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.8)"><em>str</em></a>) – <p>Type of padding. Should be: constant, edge, reflect or symmetric.
Default is constant.</p>
<ul>
<li>constant: pads with a constant value, this value is specified with fill</li>
<li>edge: pads with the last value at the edge of the image</li>
<li>reflect: pads with reflection of image without repeating the last value on the edge<blockquote>
<div>For example, padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]</div></blockquote>
</li>
<li>symmetric: pads with reflection of image repeating the last value on the edge<blockquote>
<div>For example, padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]</div></blockquote>
</li>
</ul>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomAffine">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomAffine</code><span class="sig-paren">(</span><em>degrees</em>, <em>translate=None</em>, <em>scale=None</em>, <em>shear=None</em>, <em>resample=False</em>, <em>fillcolor=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomAffine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomAffine" title="Permalink to this definition">¶</a></dt>
<dd><p>Random affine transformation of the image keeping center invariant</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>degrees</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Range of degrees to select from.
If degrees is a number instead of sequence like (min, max), the range of degrees
will be (-degrees, +degrees). Set to 0 to deactivate rotations.</li>
<li><strong>translate</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a><em>, </em><em>optional</em>) – tuple of maximum absolute fraction for horizontal
and vertical translations. For example translate=(a, b), then horizontal shift
is randomly sampled in the range -img_width * a &lt; dx &lt; img_width * a and vertical shift is
randomly sampled in the range -img_height * b &lt; dy &lt; img_height * b. Will not translate by default.</li>
<li><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a><em>, </em><em>optional</em>) – scaling factor interval, e.g (a, b), then scale is
randomly sampled from the range a &lt;= scale &lt;= b. Will keep original scale by default.</li>
<li><strong>shear</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em>, </em><em>optional</em>) – Range of degrees to select from.
If shear is a number, a shear parallel to the x axis in the range (-shear, +shear)
will be apllied. Else if shear is a tuple or list of 2 values a shear parallel to the x axis in the
range (shear[0], shear[1]) will be applied. Else if shear is a tuple or list of 4 values,
a x-axis shear in (shear[0], shear[1]) and y-axis shear in (shear[2], shear[3]) will be applied.
Will not apply shear by default</li>
<li><strong>resample</strong> (<em>{PIL.Image.NEAREST</em><em>, </em><em>PIL.Image.BILINEAR</em><em>, </em><em>PIL.Image.BICUBIC}</em><em>, </em><em>optional</em>) – An optional resampling filter. See <a class="reference external" href="https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters">filters</a> for more information.
If omitted, or if the image has mode “1” or “P”, it is set to PIL.Image.NEAREST.</li>
<li><strong>fillcolor</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Optional fill color (Tuple for RGB Image And int for grayscale) for the area
outside the transform in the output image.(Pillow&gt;=5.0.0)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomApply">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomApply</code><span class="sig-paren">(</span><em>transforms</em>, <em>p=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomApply"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomApply" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply randomly a list of transformations with a given probability</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>transforms</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><em>list</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a>) – list of transformations</li>
<li><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – probability</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomChoice">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomChoice</code><span class="sig-paren">(</span><em>transforms</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomChoice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomChoice" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply single transformation randomly picked from a list</p>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomCrop</code><span class="sig-paren">(</span><em>size</em>, <em>padding=None</em>, <em>pad_if_needed=False</em>, <em>fill=0</em>, <em>padding_mode='constant'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image at a random location.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</li>
<li><strong>padding</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><em>sequence</em><em>, </em><em>optional</em>) – Optional padding on each border
of the image. Default is None, i.e no padding. If a sequence of length
4 is provided, it is used to pad left, top, right, bottom borders
respectively. If a sequence of length 2 is provided, it is used to
pad left/right, top/bottom borders, respectively.</li>
<li><strong>pad_if_needed</strong> (<em>boolean</em>) – It will pad the image if smaller than the
desired size to avoid raising an exception. Since cropping is done
after padding, the padding seems to be done at a random offset.</li>
<li><strong>fill</strong> – Pixel fill value for constant fill. Default is 0. If a tuple of
length 3, it is used to fill R, G, B channels respectively.
This value is only used when the padding_mode is constant</li>
<li><strong>padding_mode</strong> – <p>Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.</p>
<ul>
<li>constant: pads with a constant value, this value is specified with fill</li>
<li>edge: pads with the last value on the edge of the image</li>
<li>reflect: pads with reflection of image (without repeating the last value on the edge)<blockquote>
<div>padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]</div></blockquote>
</li>
<li>symmetric: pads with reflection of image (repeating the last value on the edge)<blockquote>
<div>padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]</div></blockquote>
</li>
</ul>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomGrayscale">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomGrayscale</code><span class="sig-paren">(</span><em>p=0.1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomGrayscale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomGrayscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly convert image to grayscale with a probability of p (default 0.1).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – probability that image should be converted to grayscale.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Grayscale version of the input image with probability p and unchanged
with probability (1-p).
- If input image is 1 channel: grayscale version is 1 channel
- If input image is 3 channel: grayscale version is 3 channel with r == g == b</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomHorizontalFlip">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomHorizontalFlip</code><span class="sig-paren">(</span><em>p=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomHorizontalFlip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomHorizontalFlip" title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally flip the given PIL Image randomly with a given probability.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – probability of the image being flipped. Default value is 0.5</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomOrder">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomOrder</code><span class="sig-paren">(</span><em>transforms</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomOrder"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomOrder" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a list of transformations in a random order</p>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomPerspective">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomPerspective</code><span class="sig-paren">(</span><em>distortion_scale=0.5</em>, <em>p=0.5</em>, <em>interpolation=3</em>, <em>fill=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomPerspective"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomPerspective" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs Perspective transformation of the given PIL Image randomly with a given probability.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>interpolation</strong> – Default- Image.BICUBIC</li>
<li><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – probability of the image being perspectively transformed. Default value is 0.5</li>
<li><strong>distortion_scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – it controls the degree of distortion and ranges from 0 to 1. Default value is 0.5.</li>
<li><strong>fill</strong> (<em>3-tuple</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – RGB pixel fill value for area outside the rotated image.
If int, it is used for all channels respectively. Default value is 0.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomResizedCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomResizedCrop</code><span class="sig-paren">(</span><em>size</em>, <em>scale=(0.08</em>, <em>1.0)</em>, <em>ratio=(0.75</em>, <em>1.3333333333333333)</em>, <em>interpolation=2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomResizedCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomResizedCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image to random size and aspect ratio.</p>
<p>A crop of random size (default: of 0.08 to 1.0) of the original size and a random
aspect ratio (default: of 3/4 to 4/3) of the original aspect ratio is made. This crop
is finally resized to given size.
This is popularly used to train the Inception networks.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> – expected output size of each edge</li>
<li><strong>scale</strong> – range of size of the origin size cropped</li>
<li><strong>ratio</strong> – range of aspect ratio of the origin aspect ratio cropped</li>
<li><strong>interpolation</strong> – Default: PIL.Image.BILINEAR</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomRotation">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomRotation</code><span class="sig-paren">(</span><em>degrees</em>, <em>resample=False</em>, <em>expand=False</em>, <em>center=None</em>, <em>fill=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomRotation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomRotation" title="Permalink to this definition">¶</a></dt>
<dd><p>Rotate the image by angle.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>degrees</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Range of degrees to select from.
If degrees is a number instead of sequence like (min, max), the range of degrees
will be (-degrees, +degrees).</li>
<li><strong>resample</strong> (<em>{PIL.Image.NEAREST</em><em>, </em><em>PIL.Image.BILINEAR</em><em>, </em><em>PIL.Image.BICUBIC}</em><em>, </em><em>optional</em>) – An optional resampling filter. See <a class="reference external" href="https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters">filters</a> for more information.
If omitted, or if the image has mode “1” or “P”, it is set to PIL.Image.NEAREST.</li>
<li><strong>expand</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Optional expansion flag.
If true, expands the output to make it large enough to hold the entire rotated image.
If false or omitted, make the output image the same size as the input image.
Note that the expand flag assumes rotation around the center and no translation.</li>
<li><strong>center</strong> (<em>2-tuple</em><em>, </em><em>optional</em>) – Optional center of rotation.
Origin is the upper left corner.
Default is the center of the image.</li>
<li><strong>fill</strong> (<em>n-tuple</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – Pixel fill value for area outside the rotated
image. If int or float, the value is used for all bands respectively.
Defaults to 0 for all bands. This option is only available for <code class="docutils literal notranslate"><span class="pre">pillow&gt;=5.2.0</span></code>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomSizedCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomSizedCrop</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomSizedCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomSizedCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Note: This transform is deprecated in favor of RandomResizedCrop.</p>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomVerticalFlip">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomVerticalFlip</code><span class="sig-paren">(</span><em>p=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomVerticalFlip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomVerticalFlip" title="Permalink to this definition">¶</a></dt>
<dd><p>Vertically flip the given PIL Image randomly with a given probability.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – probability of the image being flipped. Default value is 0.5</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.Resize">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Resize</code><span class="sig-paren">(</span><em>size</em>, <em>interpolation=2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Resize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Resize" title="Permalink to this definition">¶</a></dt>
<dd><p>Resize the input PIL Image to the given size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size. If size is a sequence like
(h, w), output size will be matched to this. If size is an int,
smaller edge of the image will be matched to this number.
i.e, if height &gt; width, then image will be rescaled to
(size * height / width, size)</li>
<li><strong>interpolation</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em>, </em><em>optional</em>) – Desired interpolation. Default is
<code class="docutils literal notranslate"><span class="pre">PIL.Image.BILINEAR</span></code></li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.Scale">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Scale</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Scale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Scale" title="Permalink to this definition">¶</a></dt>
<dd><p>Note: This transform is deprecated in favor of Resize.</p>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.TenCrop">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">TenCrop</code><span class="sig-paren">(</span><em>size</em>, <em>vertical_flip=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#TenCrop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.TenCrop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image into four corners and the central crop plus the flipped version of
these (horizontal flipping is used by default)</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform returns a tuple of images and there may be a mismatch in the number of
inputs and targets your Dataset returns. See below for an example of how to deal with
this.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</li>
<li><strong>vertical_flip</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – Use vertical flipping instead of horizontal</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">transform</span> <span class="o">=</span> <span class="n">Compose</span><span class="p">([</span>
<span class="gp">&gt;&gt;&gt; </span>   <span class="n">TenCrop</span><span class="p">(</span><span class="n">size</span><span class="p">),</span> <span class="c1"># this is a list of PIL Images</span>
<span class="gp">&gt;&gt;&gt; </span>   <span class="n">Lambda</span><span class="p">(</span><span class="k">lambda</span> <span class="n">crops</span><span class="p">:</span> <span class="n">torch</span><span class="o">.</span><span class="n">stack</span><span class="p">([</span><span class="n">ToTensor</span><span class="p">()(</span><span class="n">crop</span><span class="p">)</span> <span class="k">for</span> <span class="n">crop</span> <span class="ow">in</span> <span class="n">crops</span><span class="p">]))</span> <span class="c1"># returns a 4D tensor</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="c1">#In your test loop you can do the following:</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">input</span><span class="p">,</span> <span class="n">target</span> <span class="o">=</span> <span class="n">batch</span> <span class="c1"># input is a 5d tensor, target is 2d</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span> <span class="o">=</span> <span class="nb">input</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">result</span> <span class="o">=</span> <span class="n">model</span><span class="p">(</span><span class="nb">input</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">w</span><span class="p">))</span> <span class="c1"># fuse batch size and ncrops</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">result_avg</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">view</span><span class="p">(</span><span class="n">bs</span><span class="p">,</span> <span class="n">ncrops</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># avg over crops</span>
</pre></div>
</div>
</dd></dl>

</div>
<div class="section" id="transforms-on-torch-tensor">
<h2>Transforms on torch.*Tensor<a class="headerlink" href="#transforms-on-torch-tensor" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.LinearTransformation">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">LinearTransformation</code><span class="sig-paren">(</span><em>transformation_matrix</em>, <em>mean_vector</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#LinearTransformation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.LinearTransformation" title="Permalink to this definition">¶</a></dt>
<dd><p>Transform a tensor image with a square transformation matrix and a mean_vector computed
offline.
Given transformation_matrix and mean_vector, will flatten the torch.*Tensor and
subtract mean_vector from it which is then followed by computing the dot
product with the transformation matrix and then reshaping the tensor to its
original shape.</p>
<dl class="docutils">
<dt>Applications:</dt>
<dd>whitening transformation: Suppose X is a column vector zero-centered data.
Then compute the data covariance matrix [D x D] with torch.mm(X.t(), X),
perform SVD on this matrix and pass it as transformation_matrix.</dd>
</dl>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>transformation_matrix</strong> (<em>Tensor</em>) – tensor [D x D], D = C x H x W</li>
<li><strong>mean_vector</strong> (<em>Tensor</em>) – tensor [D], D = C x H x W</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.Normalize">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Normalize</code><span class="sig-paren">(</span><em>mean</em>, <em>std</em>, <em>inplace=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Normalize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Normalize" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalize a tensor image with mean and standard deviation.
Given mean: <code class="docutils literal notranslate"><span class="pre">(M1,...,Mn)</span></code> and std: <code class="docutils literal notranslate"><span class="pre">(S1,..,Sn)</span></code> for <code class="docutils literal notranslate"><span class="pre">n</span></code> channels, this transform
will normalize each channel of the input <code class="docutils literal notranslate"><span class="pre">torch.*Tensor</span></code> i.e.
<code class="docutils literal notranslate"><span class="pre">output[channel]</span> <span class="pre">=</span> <span class="pre">(input[channel]</span> <span class="pre">-</span> <span class="pre">mean[channel])</span> <span class="pre">/</span> <span class="pre">std[channel]</span></code></p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform acts out of place, i.e., it does not mutate the input tensor.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mean</strong> (<em>sequence</em>) – Sequence of means for each channel.</li>
<li><strong>std</strong> (<em>sequence</em>) – Sequence of standard deviations for each channel.</li>
<li><strong>inplace</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>,</em><em>optional</em>) – Bool to make this operation in-place.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="torchvision.transforms.Normalize.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>tensor</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Normalize.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Normalize.__call__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>tensor</strong> (<em>Tensor</em>) – Tensor image of size (C, H, W) to be normalized.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Normalized Tensor image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Tensor</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.RandomErasing">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">RandomErasing</code><span class="sig-paren">(</span><em>p=0.5</em>, <em>scale=(0.02</em>, <em>0.33)</em>, <em>ratio=(0.3</em>, <em>3.3)</em>, <em>value=0</em>, <em>inplace=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#RandomErasing"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.RandomErasing" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomly selects a rectangle region in an image and erases its pixels.
‘Random Erasing Data Augmentation’ by Zhong et al. See <a class="reference external" href="https://arxiv.org/pdf/1708.04896.pdf">https://arxiv.org/pdf/1708.04896.pdf</a></p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>p</strong> – probability that the random erasing operation will be performed.</li>
<li><strong>scale</strong> – range of proportion of erased area against input image.</li>
<li><strong>ratio</strong> – range of aspect ratio of erased area.</li>
<li><strong>value</strong> – erasing value. Default is 0. If a single int, it is used to
erase all pixels. If a tuple of length 3, it is used to erase
R, G, B channels respectively.
If a str of ‘random’, erasing each pixel with random values.</li>
<li><strong>inplace</strong> – boolean to make this transform inplace. Default set to False.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Erased Image.</p>
</td>
</tr>
</tbody>
</table>
<dl class="docutils">
<dt># Examples:</dt>
<dd><div class="first last highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">transform</span> <span class="o">=</span> <span class="n">transforms</span><span class="o">.</span><span class="n">Compose</span><span class="p">([</span>
<span class="gp">&gt;&gt;&gt; </span>  <span class="n">transforms</span><span class="o">.</span><span class="n">RandomHorizontalFlip</span><span class="p">(),</span>
<span class="gp">&gt;&gt;&gt; </span>  <span class="n">transforms</span><span class="o">.</span><span class="n">ToTensor</span><span class="p">(),</span>
<span class="gp">&gt;&gt;&gt; </span>  <span class="n">transforms</span><span class="o">.</span><span class="n">Normalize</span><span class="p">((</span><span class="mf">0.485</span><span class="p">,</span> <span class="mf">0.456</span><span class="p">,</span> <span class="mf">0.406</span><span class="p">),</span> <span class="p">(</span><span class="mf">0.229</span><span class="p">,</span> <span class="mf">0.224</span><span class="p">,</span> <span class="mf">0.225</span><span class="p">)),</span>
<span class="gp">&gt;&gt;&gt; </span>  <span class="n">transforms</span><span class="o">.</span><span class="n">RandomErasing</span><span class="p">(),</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">])</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="conversion-transforms">
<h2>Conversion Transforms<a class="headerlink" href="#conversion-transforms" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.ToPILImage">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">ToPILImage</code><span class="sig-paren">(</span><em>mode=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#ToPILImage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToPILImage" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a tensor or an ndarray to PIL Image.</p>
<p>Converts a torch.*Tensor of shape C x H x W or a numpy ndarray of shape
H x W x C to a PIL Image while preserving the value range.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mode</strong> (<a class="reference external" href="https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes">PIL.Image mode</a>) – <p>color space and pixel depth of input data (optional).
If <code class="docutils literal notranslate"><span class="pre">mode</span></code> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (default) there are some assumptions made about the input data:</p>
<blockquote>
<div><ul class="simple">
<li>If the input has 4 channels, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is assumed to be <code class="docutils literal notranslate"><span class="pre">RGBA</span></code>.</li>
<li>If the input has 3 channels, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is assumed to be <code class="docutils literal notranslate"><span class="pre">RGB</span></code>.</li>
<li>If the input has 2 channels, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is assumed to be <code class="docutils literal notranslate"><span class="pre">LA</span></code>.</li>
<li>If the input has 1 channel, the <code class="docutils literal notranslate"><span class="pre">mode</span></code> is determined by the data type (i.e <code class="docutils literal notranslate"><span class="pre">int</span></code>, <code class="docutils literal notranslate"><span class="pre">float</span></code>,
<code class="docutils literal notranslate"><span class="pre">short</span></code>).</li>
</ul>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="torchvision.transforms.ToPILImage.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>pic</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#ToPILImage.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToPILImage.__call__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pic</strong> (<em>Tensor</em><em> or </em><a class="reference external" href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.17)"><em>numpy.ndarray</em></a>) – Image to be converted to PIL Image.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Image converted to PIL Image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="torchvision.transforms.ToTensor">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">ToTensor</code><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#ToTensor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToTensor" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <code class="docutils literal notranslate"><span class="pre">PIL</span> <span class="pre">Image</span></code> or <code class="docutils literal notranslate"><span class="pre">numpy.ndarray</span></code> to tensor.</p>
<p>Converts a PIL Image or numpy.ndarray (H x W x C) in the range
[0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 1.0]
if the PIL Image belongs to one of the modes (L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK, 1)
or if the numpy.ndarray has dtype = np.uint8</p>
<p>In the other cases, tensors are returned without scaling.</p>
<dl class="method">
<dt id="torchvision.transforms.ToTensor.__call__">
<code class="descname">__call__</code><span class="sig-paren">(</span><em>pic</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#ToTensor.__call__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.ToTensor.__call__" title="Permalink to this definition">¶</a></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pic</strong> (<em>PIL Image</em><em> or </em><a class="reference external" href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.17)"><em>numpy.ndarray</em></a>) – Image to be converted to tensor.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Converted image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Tensor</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="generic-transforms">
<h2>Generic Transforms<a class="headerlink" href="#generic-transforms" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="torchvision.transforms.Lambda">
<em class="property">class </em><code class="descclassname">torchvision.transforms.</code><code class="descname">Lambda</code><span class="sig-paren">(</span><em>lambd</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/transforms.html#Lambda"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.Lambda" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply a user-defined lambda as a transform.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>lambd</strong> (<em>function</em>) – Lambda/function to be used for transform.</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
<div class="section" id="functional-transforms">
<h2>Functional Transforms<a class="headerlink" href="#functional-transforms" title="Permalink to this headline">¶</a></h2>
<p>Functional transforms give you fine-grained control of the transformation pipeline.
As opposed to the transformations above, functional transforms don’t contain a random number
generator for their parameters.
That means you have to specify/generate all parameters, but you can reuse the functional transform.</p>
<p>Example:
you can apply a functional transform with the same parameters to multiple images like this:</p>
<div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torchvision.transforms.functional</span> <span class="k">as</span> <span class="nn">TF</span>
<span class="kn">import</span> <span class="nn">random</span>

<span class="k">def</span> <span class="nf">my_segmentation_transforms</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">segmentation</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">random</span><span class="o">.</span><span class="n">random</span><span class="p">()</span> <span class="o">&gt;</span> <span class="mf">0.5</span><span class="p">:</span>
        <span class="n">angle</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="o">-</span><span class="mi">30</span><span class="p">,</span> <span class="mi">30</span><span class="p">)</span>
        <span class="n">image</span> <span class="o">=</span> <span class="n">TF</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">angle</span><span class="p">)</span>
        <span class="n">segmentation</span> <span class="o">=</span> <span class="n">TF</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="n">segmentation</span><span class="p">,</span> <span class="n">angle</span><span class="p">)</span>
    <span class="c1"># more transforms ...</span>
    <span class="k">return</span> <span class="n">image</span><span class="p">,</span> <span class="n">segmentation</span>
</pre></div>
</div>
<p>Example:
you can use a functional transform to build transform classes with custom behavior:</p>
<div class="code python highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">torchvision.transforms.functional</span> <span class="k">as</span> <span class="nn">TF</span>
<span class="kn">import</span> <span class="nn">random</span>

<span class="k">class</span> <span class="nc">MyRotationTransform</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;Rotate by one of the given angles.&quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">angles</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">angles</span> <span class="o">=</span> <span class="n">angles</span>

    <span class="k">def</span> <span class="fm">__call__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
        <span class="n">angle</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">angles</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">TF</span><span class="o">.</span><span class="n">rotate</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">angle</span><span class="p">)</span>

<span class="n">rotation_transform</span> <span class="o">=</span> <span class="n">MyRotationTransform</span><span class="p">(</span><span class="n">angles</span><span class="o">=</span><span class="p">[</span><span class="o">-</span><span class="mi">30</span><span class="p">,</span> <span class="o">-</span><span class="mi">15</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">15</span><span class="p">,</span> <span class="mi">30</span><span class="p">])</span>
</pre></div>
</div>
<span class="target" id="module-torchvision.transforms.functional"></span><dl class="function">
<dt id="torchvision.transforms.functional.adjust_brightness">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_brightness</code><span class="sig-paren">(</span><em>img</em>, <em>brightness_factor</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#adjust_brightness"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_brightness" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust brightness of an Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>brightness_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – How much to adjust the brightness. Can be
any non negative number. 0 gives a black image, 1 gives the
original image while 2 increases the brightness by a factor of 2.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Brightness adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.adjust_contrast">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_contrast</code><span class="sig-paren">(</span><em>img</em>, <em>contrast_factor</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#adjust_contrast"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_contrast" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust contrast of an Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>contrast_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – How much to adjust the contrast. Can be any
non negative number. 0 gives a solid gray image, 1 gives the
original image while 2 increases the contrast by a factor of 2.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Contrast adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.adjust_gamma">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_gamma</code><span class="sig-paren">(</span><em>img</em>, <em>gamma</em>, <em>gain=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#adjust_gamma"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_gamma" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform gamma correction on an image.</p>
<p>Also known as Power Law Transform. Intensities in RGB mode are adjusted
based on the following equation:</p>
<div class="math notranslate nohighlight">
\[I_{\text{out}} = 255 \times \text{gain} \times \left(\frac{I_{\text{in}}}{255}\right)^{\gamma}\]</div>
<p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Gamma_correction">Gamma Correction</a> for more details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>gamma</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – Non negative real number, same as <span class="math notranslate nohighlight">\(\gamma\)</span> in the equation.
gamma larger than 1 make the shadows darker,
while gamma smaller than 1 make dark regions lighter.</li>
<li><strong>gain</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – The constant multiplier.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.adjust_hue">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_hue</code><span class="sig-paren">(</span><em>img</em>, <em>hue_factor</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#adjust_hue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_hue" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust hue of an image.</p>
<p>The image hue is adjusted by converting the image to HSV and
cyclically shifting the intensities in the hue channel (H).
The image is then converted back to original image mode.</p>
<p><cite>hue_factor</cite> is the amount of shift in H channel and must be in the
interval <cite>[-0.5, 0.5]</cite>.</p>
<p>See <a class="reference external" href="https://en.wikipedia.org/wiki/Hue">Hue</a> for more details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>hue_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – How much to shift the hue channel. Should be in
[-0.5, 0.5]. 0.5 and -0.5 give complete reversal of hue channel in
HSV space in positive and negative direction respectively.
0 means no shift. Therefore, both -0.5 and 0.5 will give an image
with complementary colors while 0 gives the original image.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Hue adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.adjust_saturation">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">adjust_saturation</code><span class="sig-paren">(</span><em>img</em>, <em>saturation_factor</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#adjust_saturation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.adjust_saturation" title="Permalink to this definition">¶</a></dt>
<dd><p>Adjust color saturation of an image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be adjusted.</li>
<li><strong>saturation_factor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – How much to adjust the saturation. 0 will
give a black and white image, 1 will give the original image while
2 will enhance the saturation by a factor of 2.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Saturation adjusted image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.affine">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">affine</code><span class="sig-paren">(</span><em>img</em>, <em>angle</em>, <em>translate</em>, <em>scale</em>, <em>shear</em>, <em>resample=0</em>, <em>fillcolor=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#affine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.affine" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply affine transformation on the image keeping image center invariant</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be rotated.</li>
<li><strong>angle</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – rotation angle in degrees between -180 and 180, clockwise direction.</li>
<li><strong>translate</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><em>list</em></a><em> or </em><em>tuple of python:integers</em>) – horizontal and vertical translations (post-rotation translation)</li>
<li><strong>scale</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – overall scale</li>
<li><strong>shear</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><em>list</em></a>) – shear angle value in degrees between -180 to 180, clockwise direction.</li>
<li><strong>a tuple of list is specified, the first value corresponds to a shear parallel to the x axis, while</strong> (<em>If</em>) – </li>
<li><strong>second value corresponds to a shear parallel to the y axis.</strong> (<em>the</em>) – </li>
<li><strong>resample</strong> (<code class="docutils literal notranslate"><span class="pre">PIL.Image.NEAREST</span></code> or <code class="docutils literal notranslate"><span class="pre">PIL.Image.BILINEAR</span></code> or <code class="docutils literal notranslate"><span class="pre">PIL.Image.BICUBIC</span></code>, optional) – An optional resampling filter.
See <a class="reference external" href="https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters">filters</a> for more information.
If omitted, or if the image has mode “1” or “P”, it is set to <code class="docutils literal notranslate"><span class="pre">PIL.Image.NEAREST</span></code>.</li>
<li><strong>fillcolor</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Optional fill color for the area outside the transform in the output image. (Pillow&gt;=5.0.0)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.center_crop">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">center_crop</code><span class="sig-paren">(</span><em>img</em>, <em>output_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#center_crop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.center_crop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image and resize it to desired size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – Image to be cropped. (0,0) denotes the top left corner of the image.</li>
<li><strong>output_size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – (height, width) of the crop box. If int,
it is used for both directions</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Cropped image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.crop">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">crop</code><span class="sig-paren">(</span><em>img</em>, <em>top</em>, <em>left</em>, <em>height</em>, <em>width</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#crop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.crop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – Image to be cropped. (0,0) denotes the top left corner of the image.</li>
<li><strong>top</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Vertical component of the top left corner of the crop box.</li>
<li><strong>left</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Horizontal component of the top left corner of the crop box.</li>
<li><strong>height</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Height of the crop box.</li>
<li><strong>width</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Width of the crop box.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Cropped image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.erase">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">erase</code><span class="sig-paren">(</span><em>img</em>, <em>i</em>, <em>j</em>, <em>h</em>, <em>w</em>, <em>v</em>, <em>inplace=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#erase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.erase" title="Permalink to this definition">¶</a></dt>
<dd><p>Erase the input Tensor Image with given value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>Tensor Image</em>) – Tensor image of size (C, H, W) to be erased</li>
<li><strong>i</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – i in (i,j) i.e coordinates of the upper left corner.</li>
<li><strong>j</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – j in (i,j) i.e coordinates of the upper left corner.</li>
<li><strong>h</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Height of the erased region.</li>
<li><strong>w</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Width of the erased region.</li>
<li><strong>v</strong> – Erasing value.</li>
<li><strong>inplace</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – For in-place operations. By default is set False.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Erased image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Tensor Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.five_crop">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">five_crop</code><span class="sig-paren">(</span><em>img</em>, <em>size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#five_crop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.five_crop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image into four corners and the central crop.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform returns a tuple of images and there may be a
mismatch in the number of inputs and targets your <code class="docutils literal notranslate"><span class="pre">Dataset</span></code> returns.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="docutils">
<dt>tuple (tl, tr, bl, br, center)</dt>
<dd>Corresponding top left, top right, bottom left, bottom right and center crop.</dd>
</dl>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)">tuple</a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.hflip">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">hflip</code><span class="sig-paren">(</span><em>img</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#hflip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.hflip" title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally flip the given PIL Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>img</strong> (<em>PIL Image</em>) – Image to be flipped.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Horizontall flipped image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.normalize">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">normalize</code><span class="sig-paren">(</span><em>tensor</em>, <em>mean</em>, <em>std</em>, <em>inplace=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#normalize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.normalize" title="Permalink to this definition">¶</a></dt>
<dd><p>Normalize a tensor image with mean and standard deviation.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform acts out of place by default, i.e., it does not mutates the input tensor.</p>
</div>
<p>See <a class="reference internal" href="#torchvision.transforms.Normalize" title="torchvision.transforms.Normalize"><code class="xref py py-class docutils literal notranslate"><span class="pre">Normalize</span></code></a> for more details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>tensor</strong> (<em>Tensor</em>) – Tensor image of size (C, H, W) to be normalized.</li>
<li><strong>mean</strong> (<em>sequence</em>) – Sequence of means for each channel.</li>
<li><strong>std</strong> (<em>sequence</em>) – Sequence of standard deviations for each channel.</li>
<li><strong>inplace</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>,</em><em>optional</em>) – Bool to make this operation inplace.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Normalized Tensor image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">Tensor</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.pad">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">pad</code><span class="sig-paren">(</span><em>img</em>, <em>padding</em>, <em>fill=0</em>, <em>padding_mode='constant'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#pad"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.pad" title="Permalink to this definition">¶</a></dt>
<dd><p>Pad the given PIL Image on all sides with specified padding mode and fill value.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – Image to be padded.</li>
<li><strong>padding</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><em>tuple</em></a>) – Padding on each border. If a single int is provided this
is used to pad all borders. If tuple of length 2 is provided this is the padding
on left/right and top/bottom respectively. If a tuple of length 4 is provided
this is the padding for the left, top, right and bottom borders
respectively.</li>
<li><strong>fill</strong> – Pixel fill value for constant fill. Default is 0. If a tuple of
length 3, it is used to fill R, G, B channels respectively.
This value is only used when the padding_mode is constant</li>
<li><strong>padding_mode</strong> – <p>Type of padding. Should be: constant, edge, reflect or symmetric. Default is constant.</p>
<ul>
<li>constant: pads with a constant value, this value is specified with fill</li>
<li>edge: pads with the last value on the edge of the image</li>
<li>reflect: pads with reflection of image (without repeating the last value on the edge)<blockquote>
<div>padding [1, 2, 3, 4] with 2 elements on both sides in reflect mode
will result in [3, 2, 1, 2, 3, 4, 3, 2]</div></blockquote>
</li>
<li>symmetric: pads with reflection of image (repeating the last value on the edge)<blockquote>
<div>padding [1, 2, 3, 4] with 2 elements on both sides in symmetric mode
will result in [2, 1, 1, 2, 3, 4, 4, 3]</div></blockquote>
</li>
</ul>
</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Padded image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.perspective">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">perspective</code><span class="sig-paren">(</span><em>img</em>, <em>startpoints</em>, <em>endpoints</em>, <em>interpolation=3</em>, <em>fill=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#perspective"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.perspective" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform perspective transform of the given PIL Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – Image to be transformed.</li>
<li><strong>startpoints</strong> – List containing [top-left, top-right, bottom-right, bottom-left] of the orignal image</li>
<li><strong>endpoints</strong> – List containing [top-left, top-right, bottom-right, bottom-left] of the transformed image</li>
<li><strong>interpolation</strong> – Default- Image.BICUBIC</li>
<li><strong>fill</strong> (<em>n-tuple</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – Pixel fill value for area outside the rotated
image. If int or float, the value is used for all bands respectively.
This option is only available for <code class="docutils literal notranslate"><span class="pre">pillow&gt;=5.0.0</span></code>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Perspectively transformed Image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.resize">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">resize</code><span class="sig-paren">(</span><em>img</em>, <em>size</em>, <em>interpolation=2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#resize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.resize" title="Permalink to this definition">¶</a></dt>
<dd><p>Resize the input PIL Image to the given size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – Image to be resized.</li>
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size. If size is a sequence like
(h, w), the output size will be matched to this. If size is an int,
the smaller edge of the image will be matched to this number maintaing
the aspect ratio. i.e, if height &gt; width, then image will be rescaled to
<span class="math notranslate nohighlight">\(\left(\text{size} \times \frac{\text{height}}{\text{width}}, \text{size}\right)\)</span></li>
<li><strong>interpolation</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em>, </em><em>optional</em>) – Desired interpolation. Default is
<code class="docutils literal notranslate"><span class="pre">PIL.Image.BILINEAR</span></code></li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Resized image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.resized_crop">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">resized_crop</code><span class="sig-paren">(</span><em>img</em>, <em>top</em>, <em>left</em>, <em>height</em>, <em>width</em>, <em>size</em>, <em>interpolation=2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#resized_crop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.resized_crop" title="Permalink to this definition">¶</a></dt>
<dd><p>Crop the given PIL Image and resize it to desired size.</p>
<p>Notably used in <a class="reference internal" href="#torchvision.transforms.RandomResizedCrop" title="torchvision.transforms.RandomResizedCrop"><code class="xref py py-class docutils literal notranslate"><span class="pre">RandomResizedCrop</span></code></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>img</strong> (<em>PIL Image</em>) – Image to be cropped. (0,0) denotes the top left corner of the image.</li>
<li><strong>top</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Vertical component of the top left corner of the crop box.</li>
<li><strong>left</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Horizontal component of the top left corner of the crop box.</li>
<li><strong>height</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Height of the crop box.</li>
<li><strong>width</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Width of the crop box.</li>
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size. Same semantics as <code class="docutils literal notranslate"><span class="pre">resize</span></code>.</li>
<li><strong>interpolation</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em>, </em><em>optional</em>) – Desired interpolation. Default is
<code class="docutils literal notranslate"><span class="pre">PIL.Image.BILINEAR</span></code>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Cropped image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">PIL Image</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.rotate">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">rotate</code><span class="sig-paren">(</span><em>img</em>, <em>angle</em>, <em>resample=False</em>, <em>expand=False</em>, <em>center=None</em>, <em>fill=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#rotate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.rotate" title="Permalink to this definition">¶</a></dt>
<dd><p>Rotate the image by angle.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>img</strong> (<em>PIL Image</em>) – PIL Image to be rotated.</li>
<li><strong>angle</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – In degrees degrees counter clockwise order.</li>
<li><strong>resample</strong> (<code class="docutils literal notranslate"><span class="pre">PIL.Image.NEAREST</span></code> or <code class="docutils literal notranslate"><span class="pre">PIL.Image.BILINEAR</span></code> or <code class="docutils literal notranslate"><span class="pre">PIL.Image.BICUBIC</span></code>, optional) – An optional resampling filter. See <a class="reference external" href="https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters">filters</a> for more information.
If omitted, or if the image has mode “1” or “P”, it is set to <code class="docutils literal notranslate"><span class="pre">PIL.Image.NEAREST</span></code>.</li>
<li><strong>expand</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a><em>, </em><em>optional</em>) – Optional expansion flag.
If true, expands the output image to make it large enough to hold the entire rotated image.
If false or omitted, make the output image the same size as the input image.
Note that the expand flag assumes rotation around the center and no translation.</li>
<li><strong>center</strong> (<em>2-tuple</em><em>, </em><em>optional</em>) – Optional center of rotation.
Origin is the upper left corner.
Default is the center of the image.</li>
<li><strong>fill</strong> (<em>n-tuple</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(in Python v3.8)"><em>float</em></a>) – Pixel fill value for area outside the rotated
image. If int or float, the value is used for all bands respectively.
Defaults to 0 for all bands. This option is only available for <code class="docutils literal notranslate"><span class="pre">pillow&gt;=5.2.0</span></code>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.ten_crop">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">ten_crop</code><span class="sig-paren">(</span><em>img</em>, <em>size</em>, <em>vertical_flip=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#ten_crop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.ten_crop" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate ten cropped images from the given PIL Image.
Crop the given PIL Image into four corners and the central crop plus the
flipped version of these (horizontal flipping is used by default).</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This transform returns a tuple of images and there may be a
mismatch in the number of inputs and targets your <code class="docutils literal notranslate"><span class="pre">Dataset</span></code> returns.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>size</strong> (<em>sequence</em><em> or </em><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.8)"><em>int</em></a>) – Desired output size of the crop. If size is an
int instead of sequence like (h, w), a square crop (size, size) is
made.</li>
<li><strong>vertical_flip</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.8)"><em>bool</em></a>) – Use vertical flipping instead of horizontal</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><dl class="docutils">
<dt>tuple (tl, tr, bl, br, center, tl_flip, tr_flip, bl_flip, br_flip, center_flip)</dt>
<dd><p class="first last">Corresponding top left, top right, bottom left, bottom right and
center crop and same for the flipped image.</p>
</dd>
</dl>
</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)">tuple</a></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.to_grayscale">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">to_grayscale</code><span class="sig-paren">(</span><em>img</em>, <em>num_output_channels=1</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#to_grayscale"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.to_grayscale" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert image to grayscale version of image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>img</strong> (<em>PIL Image</em>) – Image to be converted to grayscale.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="docutils">
<dt>Grayscale version of the image.</dt>
<dd>if num_output_channels = 1 : returned image is single channel<p class="last">if num_output_channels = 3 : returned image is 3 channel with r = g = b</p>
</dd>
</dl>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.to_pil_image">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">to_pil_image</code><span class="sig-paren">(</span><em>pic</em>, <em>mode=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#to_pil_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.to_pil_image" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a tensor or an ndarray to PIL Image.</p>
<p>See <a class="reference internal" href="#torchvision.transforms.ToPILImage" title="torchvision.transforms.ToPILImage"><code class="xref py py-class docutils literal notranslate"><span class="pre">ToPILImage</span></code></a> for more details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>pic</strong> (<em>Tensor</em><em> or </em><a class="reference external" href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.17)"><em>numpy.ndarray</em></a>) – Image to be converted to PIL Image.</li>
<li><strong>mode</strong> (<a class="reference external" href="https://pillow.readthedocs.io/en/latest/handbook/concepts.html#concept-modes">PIL.Image mode</a>) – color space and pixel depth of input data (optional).</li>
</ul>
</td>
</tr>
</tbody>
</table>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Image converted to PIL Image.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.to_tensor">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">to_tensor</code><span class="sig-paren">(</span><em>pic</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#to_tensor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.to_tensor" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <code class="docutils literal notranslate"><span class="pre">PIL</span> <span class="pre">Image</span></code> or <code class="docutils literal notranslate"><span class="pre">numpy.ndarray</span></code> to tensor.</p>
<p>See <code class="docutils literal notranslate"><span class="pre">ToTensor</span></code> for more details.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>pic</strong> (<em>PIL Image</em><em> or </em><a class="reference external" href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html#numpy.ndarray" title="(in NumPy v1.17)"><em>numpy.ndarray</em></a>) – Image to be converted to tensor.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Converted image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">Tensor</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="function">
<dt id="torchvision.transforms.functional.vflip">
<code class="descclassname">torchvision.transforms.functional.</code><code class="descname">vflip</code><span class="sig-paren">(</span><em>img</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/torchvision/transforms/functional.html#vflip"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#torchvision.transforms.functional.vflip" title="Permalink to this definition">¶</a></dt>
<dd><p>Vertically flip the given PIL Image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>img</strong> (<em>PIL Image</em>) – Image to be flipped.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">Vertically flipped image.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">PIL Image</td>
</tr>
</tbody>
</table>
</dd></dl>

</div>
</div>


             </article>
             
            </div>
            <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="utils.html" class="btn btn-neutral float-right" title="torchvision.utils" accesskey="n" rel="next">Next <img src="_static/images/chevron-right-orange.svg" class="next-page"></a>
      
      
        <a href="ops.html" class="btn btn-neutral" title="torchvision.ops" accesskey="p" rel="prev"><img src="_static/images/chevron-right-orange.svg" class="previous-page"> Previous</a>
      
    </div>
  

  

    <hr>

  

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, Torch Contributors.

    </p>
  </div>
    
      <div>
        Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
      </div>
     

</footer>

          </div>
        </div>

        <div class="pytorch-content-right" id="pytorch-content-right">
          <div class="pytorch-right-menu" id="pytorch-right-menu">
            <div class="pytorch-side-scroll" id="pytorch-side-scroll-right">
              <ul>
<li><a class="reference internal" href="#">torchvision.transforms</a><ul>
<li><a class="reference internal" href="#transforms-on-pil-image">Transforms on PIL Image</a></li>
<li><a class="reference internal" href="#transforms-on-torch-tensor">Transforms on torch.*Tensor</a></li>
<li><a class="reference internal" href="#conversion-transforms">Conversion Transforms</a></li>
<li><a class="reference internal" href="#generic-transforms">Generic Transforms</a></li>
<li><a class="reference internal" href="#functional-transforms">Functional Transforms</a></li>
</ul>
</li>
</ul>

            </div>
          </div>
        </div>
      </section>
    </div>

  


  

     
       <script type="text/javascript">
           var DOCUMENTATION_OPTIONS = {
               URL_ROOT:'./',
               VERSION:'master',
               LANGUAGE:'None',
               COLLAPSE_INDEX:false,
               FILE_SUFFIX:'.html',
               HAS_SOURCE:  true,
               SOURCELINK_SUFFIX: '.txt'
           };
       </script>
         <script type="text/javascript" src="_static/jquery.js"></script>
         <script type="text/javascript" src="_static/underscore.js"></script>
         <script type="text/javascript" src="_static/doctools.js"></script>
         <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
     

  

  <script type="text/javascript" src="_static/js/vendor/popper.min.js"></script>
  <script type="text/javascript" src="_static/js/vendor/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
  <script type="text/javascript" src="_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

  <!-- Begin Footer -->

  <div class="container-fluid docs-tutorials-resources" id="docs-tutorials-resources">
    <div class="container">
      <div class="row">
        <div class="col-md-4 text-center">
          <h2>Docs</h2>
          <p>Access comprehensive developer documentation for PyTorch</p>
          <a class="with-right-arrow" href="https://pytorch.org/docs/stable/index.html">View Docs</a>
        </div>

        <div class="col-md-4 text-center">
          <h2>Tutorials</h2>
          <p>Get in-depth tutorials for beginners and advanced developers</p>
          <a class="with-right-arrow" href="https://pytorch.org/tutorials">View Tutorials</a>
        </div>

        <div class="col-md-4 text-center">
          <h2>Resources</h2>
          <p>Find development resources and get your questions answered</p>
          <a class="with-right-arrow" href="https://pytorch.org/resources">View Resources</a>
        </div>
      </div>
    </div>
  </div>

  <footer class="site-footer">
    <div class="container footer-container">
      <div class="footer-logo-wrapper">
        <a href="https://pytorch.org/" class="footer-logo"></a>
      </div>

      <div class="footer-links-wrapper">
        <div class="footer-links-col">
          <ul>
            <li class="list-title"><a href="https://pytorch.org/">PyTorch</a></li>
            <li><a href="https://pytorch.org/get-started">Get Started</a></li>
            <li><a href="https://pytorch.org/features">Features</a></li>
            <li><a href="https://pytorch.org/ecosystem">Ecosystem</a></li>
            <li><a href="https://pytorch.org/blog/">Blog</a></li>
            <li><a href="https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md">Contributing</a></li>
          </ul>
        </div>

        <div class="footer-links-col">
          <ul>
            <li class="list-title"><a href="https://pytorch.org/resources">Resources</a></li>
            <li><a href="https://pytorch.org/tutorials">Tutorials</a></li>
            <li><a href="https://pytorch.org/docs/stable/index.html">Docs</a></li>
            <li><a href="https://discuss.pytorch.org" target="_blank">Discuss</a></li>
            <li><a href="https://github.com/pytorch/pytorch/issues" target="_blank">Github Issues</a></li>
            <li><a href="https://pytorch.org/assets/brand-guidelines/PyTorch-Brand-Guidelines.pdf" target="_blank">Brand Guidelines</a></li>
          </ul>
        </div>

        <div class="footer-links-col follow-us-col">
          <ul>
            <li class="list-title">Stay Connected</li>
            <li>
              <div id="mc_embed_signup">
                <form
                  action="https://twitter.us14.list-manage.com/subscribe/post?u=75419c71fe0a935e53dfa4a3f&id=91d0dccd39"
                  method="post"
                  id="mc-embedded-subscribe-form"
                  name="mc-embedded-subscribe-form"
                  class="email-subscribe-form validate"
                  target="_blank"
                  novalidate>
                  <div id="mc_embed_signup_scroll" class="email-subscribe-form-fields-wrapper">
                    <div class="mc-field-group">
                      <label for="mce-EMAIL" style="display:none;">Email Address</label>
                      <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="Email Address">
                    </div>

                    <div id="mce-responses" class="clear">
                      <div class="response" id="mce-error-response" style="display:none"></div>
                      <div class="response" id="mce-success-response" style="display:none"></div>
                    </div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->

                    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_75419c71fe0a935e53dfa4a3f_91d0dccd39" tabindex="-1" value=""></div>

                    <div class="clear">
                      <input type="submit" value="" name="subscribe" id="mc-embedded-subscribe" class="button email-subscribe-button">
                    </div>
                  </div>
                </form>
              </div>

            </li>
          </ul>

          <div class="footer-social-icons">
            <a href="https://www.facebook.com/pytorch" target="_blank" class="facebook"></a>
            <a href="https://twitter.com/pytorch" target="_blank" class="twitter"></a>
            <a href="https://www.youtube.com/pytorch" target="_blank" class="youtube"></a>
          </div>
        </div>
      </div>
    </div>
  </footer>

  <div class="cookie-banner-wrapper">
  <div class="container">
    <p class="gdpr-notice">To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: <a href="https://www.facebook.com/policies/cookies/">Cookies Policy</a>.</p>
    <img class="close-button" src="_static/images/pytorch-x.svg">
  </div>
</div>

  <!-- End Footer -->

  <!-- Begin Mobile Menu -->

  <div class="mobile-main-menu">
    <div class="container-fluid">
      <div class="container">
        <div class="mobile-main-menu-header-container">
          <a class="header-logo" href="https://pytorch.org/" aria-label="PyTorch"></a>
          <a class="main-menu-close-button" href="#" data-behavior="close-mobile-menu"></a>
        </div>
      </div>
    </div>

    <div class="mobile-main-menu-links-container">
      <div class="main-menu">
        <ul>
          <li>
            <a href="https://pytorch.org/get-started">Get Started</a>
          </li>

          <li>
            <a href="https://pytorch.org/features">Features</a>
          </li>

          <li>
            <a href="https://pytorch.org/ecosystem">Ecosystem</a>
          </li>

          <li>
            <a href="https://pytorch.org/mobile">Mobile</a>
          </li>

          <li>
            <a href="https://pytorch.org/hub">PyTorch Hub</a>
          </li>

          <li>
            <a href="https://pytorch.org/blog/">Blog</a>
          </li>

          <li>
            <a href="https://pytorch.org/tutorials">Tutorials</a>
          </li>

          <li class="active">
            <a href="https://pytorch.org/docs/stable/index.html">Docs</a>
          </li>

          <li>
            <a href="https://pytorch.org/resources">Resources</a>
          </li>

          <li>
            <a href="https://github.com/pytorch/pytorch">Github</a>
          </li>
        </ul>
      </div>
    </div>
  </div>

  <!-- End Mobile Menu -->

  <script type="text/javascript" src="_static/js/vendor/anchor.min.js"></script>

  <script type="text/javascript">
    $(document).ready(function() {
      mobileMenu.bind();
      mobileTOC.bind();
      pytorchAnchors.bind();
      sideMenus.bind();
      scrollToAnchor.bind();
      highlightNavigation.bind();
      mainMenuDropdown.bind();
      filterTags.bind();

      // Remove any empty p tags that Sphinx adds
      $("[data-tags='null']").remove();

      // Add class to links that have code blocks, since we cannot create links in code blocks
      $("article.pytorch-article a span.pre").each(function(e) {
        $(this).closest("a").addClass("has-code");
      });
    })
  </script>
</body>
</html>